<template>
	<view class="content">
		<view class="title">
			欢迎登录农业平台
		</view>
		<view class="account">
			<view class="text">账号</view>
			<input v-model="phone" type="number" value="" placeholder="请输入手机号" />
		</view>
		<view class="account password">
			<view class="text">密码</view>
			<input v-model="password" type="password" value="" placeholder="请输入密码" />
		</view>
		<view class="tabs">
			<view @click="navTo('/pages/enter/register')">立即注册</view>
			<view @click="navTo('/pages/enter/password?title=忘记密码')">忘记密码</view>
		</view>
		<button @click="submitLogin" class="btn" type="default" :disabled="is_btn">登录</button>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				is_btn: false,
				phone: '',
				password: ''
			}
		},
		methods:{
			submitLogin(){
				if(this.phone == ''){
					this.$u.toast('请输入正确的手机号');
					return
				}
				if(this.password == ''){
					this.$u.toast('请输入密码');
					return
				}
				this.$http.post('/api/user/login',{
					account: this.phone,
					password: this.password
				}).then(res => {
					// console.log(res)
					this.$store.commit('SAVE_USER',res.data.data.userinfo);
					uni.setStorageSync('token',res.data.data.userinfo.token);
					uni.navigateBack({
						delta:1
					})
				})
			},
			navTo(url){
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		width: 535rpx;
		margin: 0 auto;
	}
	.title{
		font-size:28px;
		font-family:PingFang SC;
		font-weight:bold;
		color:rgba(51,51,51,1);
		margin-top: 120rpx;
	}
	.account{
		margin-top: 105rpx;
		.text{
			font-size:20px;
			font-family:PingFang SC;
			font-weight:800;
			color:rgba(51,51,51,1);
		}
		input{
			border: none;
			outline: none;
			border-bottom: 1px solid #999999;
			display: block;
			width: 100%;
			height: 70rpx;
			margin-top: 30rpx;
			padding-bottom: 30rpx;
			box-sizing: border-box;
			min-height: none;
		}
	}
	.password{
		margin-top: 82rpx;
	}
	.tabs{
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 30rpx;
		margin-bottom: 100rpx;
		view{
			font-size:12px;
			font-family:PingFang SC;
			font-weight:500;
			color:rgba(63,195,119,1);
		}
	}
	.btn{
		width:535rpx;
		height:88rpx;
		background:rgba(63,195,119,1);
		border-radius:10px;
		color:rgba(255,255,255,1);
	}
</style>
